package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglGxrw;
import com.xveshe.admin.service.IXsglGxrwService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 岗训任务收发Controller
 *
 * @author 葛亚松
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/admin/gxrw")
public class XsglGxrwController extends BaseController
{
    @Autowired
    private IXsglGxrwService xsglGxrwService;

    /**
     * 查询岗训任务收发列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglGxrw xsglGxrw)
    {
        startPage();
        List<XsglGxrw> list = xsglGxrwService.selectXsglGxrwList(xsglGxrw);
        return getDataTable(list);
    }

    /**
     * 导出岗训任务收发列表
     */
    @PreAuthorize("@ss.hasPermi('admin:gxrw:export')")
    @Log(title = "岗训任务收发", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglGxrw xsglGxrw)
    {
        List<XsglGxrw> list = xsglGxrwService.selectXsglGxrwList(xsglGxrw);
        ExcelUtil<XsglGxrw> util = new ExcelUtil<XsglGxrw>(XsglGxrw.class);
        util.exportExcel(response, list, "岗训任务收发数据");
    }

    /**
     * 获取岗训任务收发详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglGxrwService.selectXsglGxrwById(id));
    }

    /**
     * 新增岗训任务收发
     */
    @PreAuthorize("@ss.hasPermi('admin:gxrw:add')")
    @Log(title = "岗训任务收发", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglGxrw xsglGxrw)
    {
        return toAjax(xsglGxrwService.insertXsglGxrw(xsglGxrw));
    }

    /**
     * 修改岗训任务收发
     */
    @PreAuthorize("@ss.hasPermi('admin:gxrw:edit')")
    @Log(title = "岗训任务收发", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglGxrw xsglGxrw)
    {
        return toAjax(xsglGxrwService.updateXsglGxrw(xsglGxrw));
    }

    /**
     * 删除岗训任务收发
     */
    @PreAuthorize("@ss.hasPermi('admin:gxrw:remove')")
    @Log(title = "岗训任务收发", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglGxrwService.deleteXsglGxrwByIds(ids));
    }
}
